package com.example.light.web.system.controller;

import com.example.light.web.system.entity.Department;
import com.example.light.web.system.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.Date;


@Controller("dept")
public class DeptController {

    @Autowired
    private DeptService deptService;

    /**
     *
     * 功能描述: 部门管理界面导入并 查询部门
     *
     * @param:
     * @return: 
     * @auther: 
     * @date:    11点05分
     * */
    @RequestMapping("/department.shtml")
    public String query(Model model){

        String path=deptService.Queryall(model);
        return path;
    }
    
    /**
     *
     * 功能描述: 部门添加界面导入
     *
     * @param:
     * @return:
     * @auther:
     * @date:
     */
    @RequestMapping("/departmentadd.shtml")
    public String deptAddView(Model model,Integer deptId)throws Exception{

        String path=deptService.dpetAddView(model,deptId);
        return path;
    }
    
    /**
     *
     * 功能描述: 部门添加
     *
     * @param: 
     * @return: 
     * @auther: 
     * @date:  
     */
    @RequestMapping("/deptadd.shtml")
    @ResponseBody
    public String deptAdd(Model model,Department dept)throws Exception{
        String path=deptService.deptAdd(model,dept);
        return path;

    }

    
    /**
     *
     * 功能描述: 部门删除
     *
     * @param: 
     * @return: 
     * @auther: 
     * @date:  
     */
    @RequestMapping("/deptdelet.shtml")
    public String deptDelet(Model model,@RequestParam(value = "deptIds[]")Integer[] ids)throws Exception{

        String path= deptService.deptDeletM(model,ids);;
        return path;

    }
    
    
    /**
     *
     * 功能描述: 修改界面导入
     *
     * @param: 
     * @return: 
     * @auther: 
     * @date:  
     */
    @RequestMapping("/departmentupdate.shtml")
    public String deptUpdateView(Model model,Department department)throws Exception{

        String path=deptService.dpetUpdateView(model,department);
        return path;
    }
    
    /**
     *
     * 功能描述: 部门修改
     *
     * @param: 
     * @return: 
     * @auther: 
     * @date:  
     */
    @RequestMapping("/deptUpdate.shtml")
    @ResponseBody
    public String deptUpdate(Model model,Department dept)throws Exception{
        String path=deptService.deptUpdate(model,dept);
        return path;

    }

}
